package icom.acm.action;

import icom.acm.action.Action;
import icom.acm.bean.T_EDUINFO;
import icom.acm.manager.T_EduInfoMgr;

public class EduInfoAction extends Action{
	private T_EDUINFO edu;
	private String token;
	
	public String record() throws Exception {
		String token = (String)session.getAttribute("token");
		if (token==null){
			return "ERROR";
		} else if (!token.equals(this.token)){
			return "ERROR";
		}
		session.removeAttribute("token");
		T_EduInfoMgr tem = new T_EduInfoMgr();
		tem.insert(edu);
		return "SUCCESS";
	}
	
	public String delete(){
		String token = (String)session.getAttribute("token");
		if (token==null){
			return "ERROR";
		} else if (!token.equals(this.token)){
			return "ERROR";
		}
		session.removeAttribute("token");
		T_EduInfoMgr tem = new T_EduInfoMgr();
		tem.delete(edu.getE_UID(), edu.getE_CID());
		return "SUCCESS";
	}
	
	public String update(){
		String token = (String)session.getAttribute("token");
		if (token==null){
			return "ERROR";
		} else if (!token.equals(this.token)){
			return "ERROR";
		}
		session.removeAttribute("token");
		T_EduInfoMgr tem = new T_EduInfoMgr();
		int id = tem.update(edu);
		if(id == -1){
			return "ERROR";
		}
		return "SUCCESS";
	}
	
	public T_EDUINFO getEdu() {
		return edu;
	}
	public void setEdu(T_EDUINFO edu) {
		this.edu = edu;
	}
	public String getToken() {
		return token;
	}
	public void setToken(String token) {
		this.token = token;
	}
}